﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true"
    CodeBehind="LotteryCompanyManager.aspx.cs" Inherits="LotteryVote.LotteryCompanyManager" %>

<asp:Content ID="Header" ContentPlaceHolderID="head" runat="server">
    <link href="Style/TableBaseStyle.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Main" ContentPlaceHolderID="main" runat="server">
    <div id="searchBar">
        <%if (CurrentUser.Role == LotteryVote.Entity.SystemRole.Company)
          { %>
        <input type="button" id="new" value='<%=GetGlobalResourceObject("Resource", "New")%>' />
        <span>
            <%=GetGlobalResourceObject("Resource","Company") %>:</span>
        <asp:DropDownList ID="ddl_company" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddl_company_SelectedIndexChanged">
        </asp:DropDownList>
        <asp:CheckBoxList ID="ck_week" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow">
        </asp:CheckBoxList>
        <asp:Button ID="btn_submit" runat="server" Text="<%$Resources:Resource,Submit %>"
            OnClick="btn_submit_Click" />
        <asp:Button ID="btn_updateTodayCompany" runat="server" 
            Text="<%$Resources:Resource,UpdateLotteryCompany %>" 
            onclick="btn_updateTodayCompany_Click" />
        <%} %>
    </div>
    <asp:Repeater ID="rpt_company" runat="server" OnItemCommand="rpt_company_ItemCommand">
        <HeaderTemplate>
            <table cellpadding="0" cellspacing="0">
                <thead>
                    <tr>
                        <td>
                            <%=GetGlobalResourceObject("Resource","No") %>
                        </td>
                        <td>
                            <%=GetGlobalResourceObject("Resource", "CompanyName")%>
                        </td>
                        <td>
                            <%=GetGlobalResourceObject("Resource", "Abbreviation")%>
                        </td>
                        <td>
                            <%=GetGlobalResourceObject("Resource","CompanyType") %>
                        </td>
                        <td>
                            <%=GetGlobalResourceObject("Resource","Region") %>
                        </td>
                        <td>
                            <%=GetGlobalResourceObject("Resource","OpenTime") %>
                        </td>
                        <td>
                            <%=GetGlobalResourceObject("Resource","CloseTime") %>
                        </td>
                        <%if (CurrentUser.Role == LotteryVote.Entity.SystemRole.Company)
                          { %>
                        <td>
                            <%=GetGlobalResourceObject("Resource", "Function")%>
                        </td>
                        <%} %>
                    </tr>
                </thead>
        </HeaderTemplate>
        <ItemTemplate>
            <tr>
                <td>
                    <%# Container.ItemIndex+1 %>
                </td>
                <td>
                    <%#Eval("Name") %>
                </td>
                <td>
                    <%#Eval("Abbreviation") %>
                </td>
                <td>
                    <%#Eval("CompanyType.TypeName")%>
                </td>
                <td>
                    <%# GetGlobalResourceObject("Resource", Eval("Region").ToString()) %>
                </td>
                <td>
                    <%#Eval("OpenTime") %>
                </td>
                <td>
                    <%#Eval("CloseTime") %>
                </td>
                <%if (CurrentUser.Role == LotteryVote.Entity.SystemRole.Company)
                  { %>
                <td>
                    <a href="javascript:void()" class="edit" company='<%#Eval("CompanyId") %>'>
                        <%=GetGlobalResourceObject("Resource", "Edit")%></a>
                    <asp:LinkButton ID="btn_del" runat="server" Text="<%$Resources:Resource,Delete %>"
                        CommandName="del" CommandArgument='<%#Eval("CompanyId") %>' OnClientClick="return confirm('Are you sure?')"></asp:LinkButton>
                </td>
                <%} %>
            </tr>
        </ItemTemplate>
        <FooterTemplate>
            </tbody> </table>
        </FooterTemplate>
    </asp:Repeater>
    <%if (CurrentUser.Role == LotteryVote.Entity.SystemRole.Company)
      { %>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#new").bind("click", function () {
                buildFrame("editFrame", 300, 450, "EditCompany.aspx");
            });
            $(".edit").bind("click", function () {
                buildFrame("editFrame", 300, 450, "EditCompany.aspx?Company=" + $(this).attr("company"));
            });
        });
    </script>
    <%} %>
</asp:Content>
